<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="lib/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="lib/admin/admin.css" media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
    <script type="text/javascript" src="lib/jquery-3.4.1.min.js"></script>
    <script type="text/javascript">
        function a() {
            layui.use('layer',function () {
                var layer = layui.layer;
                layer.open({
                    type: 2,
                    area: ['600px','400px'],
                    content: 'order_detail_audit.html'
                })
            })
        }
    </script>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title">
    <legend>订单审核</legend>
</fieldset>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">创建时间</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="test17" placeholder="yyyy-MM-dd">
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </div>
        <div class="layui-card-body">
            <div style="padding-bottom: 10px;">
                <!--                <button class="layui-btn layuiadmin-btn-list" data-type="batchdel">删除</button>-->
                <!--                <button class="layui-btn layuiadmin-btn-list" data-type="add">添加</button>-->
            </div>
            <table class="layui-hide" id="test" lay-filter="test"></table>
        </div>
    </div>
</div>


<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <!--        <button class="layui-btn layui-btn-sm" lay-event="getCheckData">获取选中行数据</button>-->
        <!--        <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button>-->
        <!--        <button class="layui-btn layui-btn-sm" lay-event="isAll">验证是否全选</button>-->
    </div>
</script>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-normal layui-btn-xs" onclick="a()">查看</a>
</script>


<script src="lib/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->

<script>
    layui.use('table', function(){

        var table = layui.table;
        table.render({
            elem: '#test'
            ,url:'order'
            ,toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            ,defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                ,layEvent: 'LAYTABLE_TIPS'
                ,icon: 'layui-icon-tips'
            }]
            ,title: '用户数据表'
            ,parseData: function(res) { //res 即为原始返回的数据
                return {
                    "code": 0, //解析接口状态
                    "msg": "", //解析提示文本
                    "count": res.total, //解析数据长度
                    "data": res.list //解析数据列表
                };
            }
            ,cols: [[
                {type: 'checkbox', fixed: 'left',width:40}
                ,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true}
                ,{field:'orderStatus', title:'订单状态', width:120, unresize: true, sort: true, templet: function(d){
                        if (d.orderStatus==2) {  // 自定义内容
                            return "已审核";
                        } else if (d.orderStatus==1) {
                            return "未审核";
                        } else {
                            return "暂存";
                        }
                    }}
                ,{field:'createDate', title:'创建时间', width:120, unresize: true, sort: true}
                ,{field:'paymentStatus', title:'支付状态', width:120, unresize: true, sort: true, templet: function(d) {
                        if (d.paymentStatus == 2) {  // 自定义内容
                            return "已付款";
                        } else if (d.paymentStatus == 1) {
                            return "未付款";
                        } else {
                            return "暂存";
                        }
                    }}
                ,{field:'amountPaid', title:'金额', width:120, unresize: true, sort: true}
                ,{field:'totalAmount', title:'总金额', width:120, unresize: true, sort: true}
                ,{field:'orderExpirationTime', title:'过期时间', width:120, unresize: true, sort: true}
                // ,{field:'email', title:'邮箱', width:150, edit: 'text', templet: function(res){
                //         return '<em>'+ res.email +'</em>'
                //     }}
                // ,{field:'sex', title:'性别', width:80, edit: 'text', sort: true}
                // ,{field:'city', title:'城市', width:100}
                // ,{field:'sign', title:'签名'}
                // ,{field:'experience', title:'积分', width:80, sort: true}
                // ,{field:'ip', title:'IP', width:120}
                // ,{field:'logins', title:'登入次数', width:100, sort: true}
                // ,{field:'birthday', title:'生日', width:120}
                ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:70}
            ]]
            ,page: true
        });

        //头工具栏事件
        table.on('toolbar(test)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            switch(obj.event){
                case 'getCheckData':
                    var data = checkStatus.data;
                    layer.alert(JSON.stringify(data));
                    break;
                case 'getCheckLength':
                    var data = checkStatus.data;
                    layer.msg('选中了：'+ data.length + ' 个');
                    break;
                case 'isAll':
                    layer.msg(checkStatus.isAll ? '全选': '未全选');
                    break;

                //自定义头工具栏右侧图标 - 提示
                case 'LAYTABLE_TIPS':
                    layer.alert('这是工具栏右侧自定义的一个图标按钮');
                    break;
            };
        });

        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            //console.log(obj)
            if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                layer.prompt({
                    formType: 2
                    ,value: data.email
                }, function(value, index){
                    obj.update({
                        email: value
                    });
                    layer.close(index);
                });
            }else if (obj.event==="audit"){
                layer.confirm('<h3 style=\'text-align: center;color: green\'>是否审核</h3>',{
                    btn:['确认审核','取消审核']
                },function (index,layero) {
                    layer.msg("审核成功",{icon:1})
                },function (index) {
                    layer.msg("审核失败",{icon:2})
                })
            }else if (obj.event==='unaudit'){
                layer.confirm('<h3 style=\'text-align: center;color: red\'>是否审核不通过</h3>',{
                    btn:['确认审核不通过','取消审核不通过']
                },function (index,layero) {
                    layer.msg("审核不通过成功",{icon:1})
                },function (index) {
                    layer.msg("审核不通过失败",{icon:2})
                })
            }
        });
    });
</script>

</body>
</html>